@@ -29,7 +29,7 @@ module Agents |
||
29 | 29 |
"subject": "{{data}}" |
30 | 30 |
} |
31 | 31 |
|
32 |
- FIXME Provide a link to a explanation on how to use liquid templating |
|
32 |
+ Have a look at the [Wiki](https://github.com/cantino/huginn/wiki/Formatting-Events-using-Liquid) to learn more about liquid templating. |
|
33 | 33 |
|
34 | 34 |
Events generated by this possible Event Formatting Agent will look like: |
35 | 35 |
|
@@ -18,7 +18,7 @@ module Agents |
||
18 | 18 |
If you want your message to notify the room members change `notify` to "true". |
19 | 19 |
Modify the background color of your message via the `color` attribute (one of "yellow", "red", "green", "purple", "gray", or "random") |
20 | 20 |
|
21 |
- TODO: add a link to the wiki explaining how to use the Liquid templating |
|
21 |
+ Have a look at the [Wiki](https://github.com/cantino/huginn/wiki/Formatting-Events-using-Liquid) to learn more about liquid templating. |
|
22 | 22 |
MD |
23 | 23 |
|
24 | 24 |
def default_options |
@@ -1,5 +1,7 @@ |
||
1 | 1 |
module Agents |
2 | 2 |
class JabberAgent < Agent |
3 |
+ include LiquidInterpolatable |
|
4 |
+ |
|
3 | 5 |
cannot_be_scheduled! |
4 | 6 |
cannot_create_events! |
5 | 7 |
|
@@ -10,7 +12,9 @@ module Agents |
||
10 | 12 |
|
11 | 13 |
The `message` is sent from `jabber_sender` to `jaber_receiver`. This message |
12 | 14 |
can contain any keys found in the source's payload, escaped using double curly braces. |
13 |
- ex: `"News Story: <$.title>: <$.url>"` |
|
15 |
+ ex: `"News Story: {{title}}: {{url}}"` |
|
16 |
+ |
|
17 |
+ Have a look at the [Wiki](https://github.com/cantino/huginn/wiki/Formatting-Events-using-Liquid) to learn more about liquid templating. |
|
14 | 18 |
MD |
15 | 19 |
|
16 | 20 |
def default_options |
@@ -20,7 +24,7 @@ module Agents |
||
20 | 24 |
'jabber_sender' => 'huginn@localhost', |
21 | 25 |
'jabber_receiver' => 'muninn@localhost', |
22 | 26 |
'jabber_password' => '', |
23 |
- 'message' => 'It will be <$.temp> out tomorrow', |
|
27 |
+ 'message' => 'It will be {{temp}} out tomorrow', |
|
24 | 28 |
'expected_receive_period_in_days' => "2" |
25 | 29 |
} |
26 | 30 |
end |
@@ -58,7 +62,7 @@ module Agents |
||
58 | 62 |
end |
59 | 63 |
|
60 | 64 |
def body(event) |
61 |
- Utils.interpolate_jsonpaths(options['message'], event.payload) |
|
65 |
+ interpolate_string(options['message'], event.payload) |
|
62 | 66 |
end |
63 | 67 |
end |
64 | 68 |
end |
@@ -20,7 +20,7 @@ module Agents |
||
20 | 20 |
|
21 | 21 |
You can provide a `title` and a `body`. |
22 | 22 |
|
23 |
- In every value of the options hash you can use the [Liquid templating syntax](http://liquidmarkup.org/). |
|
23 |
+ In every value of the options hash you can use the liquid templating, learn more about it at the [Wiki](https://github.com/cantino/huginn/wiki/Formatting-Events-using-Liquid). |
|
24 | 24 |
MD |
25 | 25 |
|
26 | 26 |
def default_options |
@@ -0,0 +1,7 @@ |
||
1 |
+class MigrateJabberAgentToLiquid < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ Agent.where(:type => 'Agents::JabberAgent').each do |agent| |
|
4 |
+ LiquidMigrator.convert_all_agent_options(agent) |
|
5 |
+ end |
|
6 |
+ end |
|
7 |
+end |
@@ -1,6 +1,9 @@ |
||
1 | 1 |
require 'spec_helper' |
2 |
+require 'models/concerns/liquid_interpolatable' |
|
2 | 3 |
|
3 | 4 |
describe Agents::JabberAgent do |
5 |
+ it_behaves_like LiquidInterpolatable |
|
6 |
+ |
|
4 | 7 |
let(:sent) { [] } |
5 | 8 |
let(:config) { |
6 | 9 |
{ |
@@ -9,7 +12,7 @@ describe Agents::JabberAgent do |
||
9 | 12 |
jabber_sender: 'foo@localhost', |
10 | 13 |
jabber_receiver: 'bar@localhost', |
11 | 14 |
jabber_password: 'password', |
12 |
- message: 'Warning! <$.title> - <$.url>', |
|
15 |
+ message: 'Warning! {{title}} - {{url}}', |
|
13 | 16 |
expected_receive_period_in_days: '2' |
14 | 17 |
} |
15 | 18 |
} |